// Copyright 2015-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

html {
  height: 100%;
  cursor: inherit;
}

body {
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0;

  color: $color-gray-90;

  @include font-body-1;

  // These should match the logic in `ts/types/Settings.ts`'s `getTitleBarVisibility`.
  //
  // It'd be great if we could use the `:fullscreen` selector here, but that does not seem
  //   to work with Electron, at least on macOS.
  --title-bar-drag-area-height: 0px; // Needs to have a unit to work with `calc()`.
  --draggable-app-region: initial;
  &.os-macos:not(.full-screen) {
    --title-bar-drag-area-height: 28px;
    --draggable-app-region: drag;
  }
}

body.light-theme {
  background-color: $color-white;
  color: $color-gray-90;
}
body.dark-theme {
  background-color: $color-gray-95;
  color: $color-gray-05;
}

::-webkit-scrollbar {
  // For vertical scrollbars
  width: 9px;
  // For horizontal scrollbars
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  @include light-theme {
    background: $color-gray-25;
    border: 2px solid $color-white;
  }
  @include dark-theme {
    background: $color-gray-45;
    border: 2px solid $color-gray-90;
  }

  &:hover {
    @include light-theme {
      background: $color-gray-45;
    }
    @include dark-theme {
      background: $color-gray-25;
    }
  }
}

::-webkit-scrollbar-corner {
  @include light-theme {
    background: $color-white;
  }
  @include dark-theme {
    background: $color-black;
  }
}

audio {
  max-width: 100%;
}

.dark-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  opacity: 0.25;
  z-index: 200;

  @include light-theme {
    background-color: $color-black;
  }
  @include dark-theme {
    background-color: $color-gray-95;
  }
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: ' ';
}
.clearfix:after {
  clear: both;
}

.hide {
  display: none;
}

button {
  cursor: pointer;
  font-size: inherit;
}
button.grey {
  border-radius: 5px;
  border: solid 1px $color-gray-25;
  cursor: pointer;
  margin: 1em auto;
  padding: 1em;
  font-family: inherit;

  @include light-theme {
    color: $color-gray-60;
    background: $color-gray-02;
    box-shadow: 0 0 10px -5px $color-black-alpha-40;
  }
  @include dark-theme {
    border: solid 1px $color-gray-25;
    color: $color-gray-60;
    background: $color-gray-02;
    box-shadow: 0 0 10px -5px $color-white-alpha-60;
  }

  &:hover {
    @include light-theme {
      box-shadow: 0 0 10px -3px $color-black-alpha-60;
    }
    @include dark-theme {
      box-shadow: 0 0 10px -3px $color-white-alpha-80;
    }
  }

  &[disabled='disabled'] {
    &,
    &:hover {
      opacity: 0.5;
      box-shadow: none;
      cursor: default;
    }
  }
}

a {
  color: $ultramarine-ui-light;
}

.file-input {
  position: relative;
  .choose-file {
    cursor: pointer;
  }

  .paperclip {
    width: 32px;
    height: 32px;
    padding: 0;
    opacity: 0.5;
    border: none;
    background: transparent;

    &:focus,
    &:hover {
      opacity: 1;
    }

    outline: none;

    &:before {
      content: '';
      display: inline-block;
      width: 24px;
      height: 24px;

      @include light-theme {
        @include color-svg('../images/icons/v2/plus-24.svg', $color-gray-75);
      }
      @include dark-theme {
        @include color-svg('../images/icons/v2/plus-24.svg', $color-gray-15);
      }
    }
  }

  input[type='file'] {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: 1;
  }
}

.group-member-list {
  .container {
    outline: none;
  }
}

.banner {
  z-index: 100;

  background-color: $color-ios-blue-tint;
  color: $color-black;
  box-shadow: 0px 3px 5px 0px $color-black-alpha-20;

  position: absolute;
  top: 25px;
  right: 30px;
  left: 30px;

  padding: 5px 25px 5px 10px;

  text-align: center;
  border-radius: 10px;

  cursor: pointer;

  .warning {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: text-bottom;
    @include color-svg('../images/icons/v2/error-solid-24.svg', black);
  }

  .dismiss {
    position: absolute;
    right: 3px;
    top: 3px;

    height: 23px;
    width: 23px;
    @include color-svg('../images/icons/v2/x-24.svg', black);
  }
}

$loading-height: 16px;

.loading {
  position: relative;
  &::before {
    display: block;
    margin: 0px auto;
    content: ' ';
    height: $loading-height;
    width: $loading-height;
    border-radius: 2 * $loading-height;
    animation: rotate 1s linear infinite;

    border: solid 3px;
    border-color: $color-ios-blue-tint $color-ios-blue-tint $color-gray-02
      $color-gray-02 !important;
  }

  @keyframes rotate {
    to {
      transform: rotate(360deg);
    }
  }
}

.x {
  display: inline-block;
  float: right;
  cursor: pointer;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  padding: 3px;
  background: $color-gray-60;

  &:before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    @include color-svg('../images/icons/v2/x-24.svg', $color-white);
  }
}

@keyframes loading {
  50% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.app-migration-screen {
  display: flex;
  flex-direction: column;
}

.app-loading-screen {
  z-index: 99;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: $ultramarine-brand-light;
  color: $color-white;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  user-select: none;

  .content {
    text-align: center;
  }
  .container {
    margin-left: auto;
    margin-right: auto;
    width: 78px;
    height: 22px;
  }
  .message {
    -webkit-user-select: text;
    max-width: 35em;
    margin-left: auto;
    margin-right: auto;
  }

  .dot {
    width: 14px;
    height: 14px;
    border: 3px solid $color-white;
    border-radius: 50%;
    float: left;
    margin: 0 6px;
    transform: scale(0);

    animation: loading 1500ms ease infinite 0ms;
    &:nth-child(2) {
      animation: loading 1500ms ease infinite 333ms;
    }
    &:nth-child(3) {
      animation: loading 1500ms ease infinite 666ms;
    }
  }
}

.full-screen-flow {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;

  &.overlay {
    // .modal, used for the settings view, is 100
    z-index: 200;
  }

  color: $color-black;
  a {
    color: $ultramarine-ui-light;
  }
  background: linear-gradient(
    to bottom,
    /* (1 - 0.41) * 255 + 0.41 * 213*/ rgb(238, 238, 238) 0%,
    /* (1 - 0.19) * 255 + 0.19 * 191*/ rgb(243, 243, 243) 12%,
    rgb(255, 255, 255) 27%,
    rgb(255, 255, 255) 60%,
    /* (1 - 0.19) * 255 + 0.19 * 222*/ rgb(249, 249, 249) 85%,
    /* (1 - 0.27) * 255 + 0.27 * 98 */ rgb(213, 213, 213) 100%
  );
  display: flex;
  align-items: center;
  text-align: center;

  font-size: 10pt;
  input {
    margin-top: 1em;
    font-size: 12pt;
    border: 2px solid $ultramarine-ui-light;
    padding: 0.5em;
    text-align: center;
    width: 20em;
  }

  @media (min-height: 750px) and (min-width: 700px) {
    font-size: 14pt;

    input {
      font-size: 16pt;
    }
  }

  #qr {
    display: inline-block;

    &.ready {
      border: 5px solid $ultramarine-ui-light;
      box-shadow: 2px 2px 4px $color-black-alpha-40;
    }

    img {
      height: 20em;
      border: 5px solid $color-white;
    }

    @media (max-height: 475px) {
      img {
        width: 8em;
        height: 8em;
      }
    }

    .dot {
      width: 14px;
      height: 14px;
      border: 3px solid $ultramarine-ui-light;
      border-radius: 50%;
      float: left;
      margin: 0 6px;
      transform: scale(0);

      animation: loading 1500ms ease infinite 0ms;
      &:nth-child(2) {
        animation: loading 1500ms ease infinite 333ms;
      }
      &:nth-child(3) {
        animation: loading 1500ms ease infinite 666ms;
      }
    }

    canvas {
      display: none;
    }
  }

  .os-icon {
    height: 3em;
    width: 3em;
    vertical-align: text-bottom;
    display: inline-block;
    margin: 0.5em;

    &.apple {
      @include color-svg('../images/full-screen-flow/apple.svg', black);
    }
    &.android {
      @include color-svg('../images/full-screen-flow/android.svg', black);
    }
  }

  .header {
    font-weight: normal;
    margin-bottom: 1.5em;

    font-size: 20pt;

    @media (min-height: 750px) and (min-width: 700px) {
      font-size: 28pt;
    }
  }

  .body-text {
    max-width: 22em;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
  }
  .body-text-wide {
    max-width: 30em;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
  }

  form {
    height: 100%;
    width: 100%;
  }
  .step {
    height: 100%;
    width: 100%;
    padding: 70px 0 50px;
  }
  .step-body {
    margin-left: auto;
    margin-right: auto;
    max-width: 35em;
  }

  .inner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 100%;
  }

  .banner-image {
    margin: 1em;
    display: none;

    @media (min-height: 550px) {
      display: inline-block;
      height: 10em;
      width: 10em;
    }
  }

  .banner-icon {
    display: none;
    margin: 1em;

    // 640px by 338px is the smallest the window can go
    @media (min-height: 550px) {
      display: inline-block;
      height: 10em;
      width: 10em;
    }

    // generic
    &.check-circle-outline {
      @include color-svg(
        '../images/full-screen-flow/check-circle-outline.svg',
        $color-gray-15
      );
    }
    &.alert-outline {
      @include color-svg(
        '../images/full-screen-flow/alert-outline.svg',
        $color-gray-15
      );
    }

    // import and export
    &.folder-outline {
      @include color-svg(
        '../images/full-screen-flow/folder-outline.svg',
        $color-gray-15
      );
    }
    &.import {
      @include color-svg(
        '../images/full-screen-flow/import.svg',
        $color-gray-15
      );
    }

    // registration process
    &.lead-pencil {
      @include color-svg(
        '../images/full-screen-flow/lead-pencil.svg',
        $color-gray-15
      );
    }
    &.sync {
      @include color-svg('../images/full-screen-flow/sync.svg', $color-gray-15);
    }

    // delete
    &.alert-outline-red {
      @include color-svg(
        '../images/full-screen-flow/alert-outline.svg',
        $color-accent-red
      );
    }
    &.delete {
      @include color-svg(
        '../images/full-screen-flow/delete.svg',
        $color-gray-15
      );
    }
  }

  .button {
    cursor: pointer;
    display: inline-block;
    border: none;
    min-width: 300px;
    padding: 0.75em;
    margin-top: 1em;
    margin-left: 0.5em;
    margin-right: 0.5em;
    color: $color-white;
    background: $ultramarine-ui-light;
    box-shadow: 2px 2px 4px $color-black-alpha-40;

    font-size: 12pt;

    &.neutral {
      color: $color-black;
      background: $color-gray-15;
    }
    &.destructive {
      background: $color-accent-red;
    }

    @media (min-height: 750px) and (min-width: 700px) {
      font-size: 20pt;
    }
  }
  a.link {
    display: block;
    cursor: pointer;
    text-decoration: underline;
    margin: 0.5em;
    color: $ultramarine-ui-light;
  }

  .progress {
    text-align: center;
    padding: 1em;
    width: 80%;
    margin: auto;

    .bar-container {
      height: 1em;
      margin: 1em;
      background-color: $color-gray-02;
    }
    .bar {
      width: 100%;
      height: 100%;
      background-color: $color-ios-blue-tint;
      transition: width 0.25s;
      box-shadow: 2px 2px 4px $color-black-alpha-40;
    }
  }

  .nav {
    width: 100%;
    bottom: 50px;
    margin-top: auto;
    padding-bottom: 2em;
    padding-left: 20px;
    padding-right: 20px;

    .instructions {
      text-align: left;
      margin-left: auto;
      margin-right: auto;
      margin-bottom: 2em;
      margin-top: 2em;
      max-width: 30em;
    }
    .instructions:after {
      clear: both;
    }
    .android {
      float: left;
    }
    .apple {
      float: right;
    }
    .label {
      float: left;
    }
    .body {
      float: left;
    }
  }
}

//yellow border fix
.inbox:focus {
  outline: none;
}

.inbox {
  position: relative;
}

.overflow-hidden {
  overflow: hidden;
}
